<!-- 商品库存查询 -->
<template>
  <el-dialog title="商品查询(库存)" :visible.sync="visible" fullscreen append-to-body center>
		<el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
      <el-divider content-position="left">查询条件</el-divider>
      <el-form :inline="true" :model="dataForm" label-width="80px" @keyup.enter.native="searchHandle">
				<el-row>
					<el-col :span="8">
						<el-form-item label="商品代码">
						  <el-input v-model="dataForm.code"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="商品条码">
						  <el-input v-model="dataForm.barcode"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="商品名称">
						  <el-input v-model="dataForm.name"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
        <el-row>
        	<el-col :span="8">
        		<el-form-item label="商品类别">
        		  <el-select v-model="dataForm.ctgId" @change="ctgChangeHandle">
        		    <el-option v-for="item in goodsCtgOptions" :value="item.id" :label="item.name" :key="item.id"></el-option>
        		  </el-select>
        		</el-form-item>
        	</el-col>
        	<el-col :span="8">
        		<el-form-item label="仓位名称">
        		  {{dataForm.stockName}}
        		</el-form-item>
        	</el-col>
        	<el-col :span="8">
        		<el-form-item label="销售价格">
        			<el-row>
        				<el-col :span="11">
        						<el-input v-model="dataForm.goodsPriceMin"></el-input>
        				</el-col>
        				<el-col :span="2" style="text-align: center;">-</el-col>
        				<el-col :span="11">
        						<el-input v-model="dataForm.goodsPriceMax"></el-input>
        				</el-col>
        			</el-row>
        		</el-form-item>
        	</el-col>
        </el-row>
				<el-row>
					<el-col :span="8">
						<el-form-item label="制造商">
						  <el-input v-model="dataForm.supplyName">
								<el-button slot="append" @click="openDialog('supply')">选择</el-button>
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="商品品种">
						  <el-input v-model="dataForm.brandName">
								<el-button slot="append" @click="openDialog('brand')">选择</el-button>
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="型号">
						  <el-input v-model="dataForm.spec"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
        <el-row v-if="[1,6,8].includes(dataForm.ctgId)">
          <el-col :span="8" v-if="dataForm.ctgId == 1">
            <el-form-item label="厂家色号">
              <el-input v-model="dataForm.manufacturerColorNumber"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="dataForm.ctgId == 8">
            <el-form-item label="老花镜度数" label-width="100px">
            	<el-row>
            		<el-col :span="11">
            			<el-input v-model="dataForm.mirrorBallMin"></el-input>
            		</el-col>
            		<el-col :span="2" style="text-align: center;">-</el-col>
            		<el-col :span="11">
            			<el-input v-model="dataForm.mirrorBallMax"></el-input>
            		</el-col>
            	</el-row>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="镜架尺寸">
              <el-input v-model="dataForm.goodsSize"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="镜架材质">
              <el-select v-model="dataForm.frameMaterial">
                <el-option v-for="item in frameMaterialData" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="dataForm.ctgId == 6"></el-col>
        </el-row>
        <el-row v-if="dataForm.ctgId == 1">
          <el-col :span="8">
            <el-form-item label="工艺类型">
              <el-select v-model="dataForm.craftType">
                <el-option v-for="item in craftTypeData" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8"></el-col>
          <el-col :span="8"></el-col>
        </el-row>
        <!-- 配件 -->
        <el-row v-if="dataForm.ctgId == 2">
          <el-col :span="8">
            <el-form-item label="配件型">
              <el-select v-model="dataForm.accessoriesType">
                <el-option v-for="item in accessoryTypeData" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8"></el-col>
          <el-col :span="8"></el-col>
        </el-row>
        <!-- 镜片 -->
        <el-row v-if="dataForm.ctgId == 3 || dataForm.ctgId == 4">
          <el-col :span="8">
            <el-form-item label="球镜范围">
            	<el-row>
            		<el-col :span="11">
            				<el-input v-model="dataForm.mirrorBallMin"></el-input>
            		</el-col>
            		<el-col :span="2" style="text-align: center;">-</el-col>
            		<el-col :span="11">
            				<el-input v-model="dataForm.mirrorBallMax"></el-input>
            		</el-col>
            	</el-row>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="柱镜范围">
            	<el-row>
            		<el-col :span="11">
            				<el-input v-model="dataForm.columnMirrorMin"></el-input>
            		</el-col>
            		<el-col :span="2" style="text-align: center;">-</el-col>
            		<el-col :span="11">
            				<el-input v-model="dataForm.columnMirrorMax"></el-input>
            		</el-col>
            	</el-row>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="镜片型">
              <el-select v-model="dataForm.customizeType">
                <el-option v-for="item in bizData.customizeTypeData" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row v-if="dataForm.ctgId == 3">
          <el-col :span="8">
            <el-form-item label="下加光">
            	<el-row>
            		<el-col :span="11">
            				<el-input v-model="dataForm.toTheLightMin"></el-input>
            		</el-col>
            		<el-col :span="2" style="text-align: center;">-</el-col>
            		<el-col :span="11">
            				<el-input v-model="dataForm.toTheLightMax"></el-input>
            		</el-col>
            	</el-row>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="材料分类">
              <el-select v-model="dataForm.lensMaterial">
                <el-option v-for="item in bizData.lensMaterial" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="折射率">
              <el-select v-model="dataForm.refractiveIndex">
                <el-option v-for="item in bizData.refractivityData" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="dataForm.ctgId == 3">
          <el-col :span="8">
            <el-form-item label="镜片分类">
              <el-select v-model="dataForm.photometricClassification">
                <el-option v-for="item in bizData.photometricClassification" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="镜片功能">
              <el-select v-model="dataForm.lensFunction">
                <el-option v-for="item in lensFunction" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="渐进片分类" label-width="100px">
              <el-select v-model="dataForm.progressiveSliceClassification">
                <el-option v-for="item in bizData.progressiveSliceClassification" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 隐形 -->
        <el-row v-if="dataForm.ctgId == 4">
          <el-col :span="8">
            <el-form-item label="使用类型">
              <el-select v-model="dataForm.useType">
                <el-option v-for="item in bizData.useType" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="抛弃型分类" label-width="100px">
              <el-select v-model="dataForm.disusedClassification">
                <el-option v-for="item in bizData.disusedClassification" :value="item.value" :label="item.label" :key="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="直径">
              <el-input v-model="dataForm.diameter"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="dataForm.ctgId == 4">
          <el-col :span="8">
            <el-form-item label="曲率">
              <el-input v-model="dataForm.curvature"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8"></el-col>
          <el-col :span="8"></el-col>
        </el-row>
        <el-row v-if="dataForm.ctgId == 5">
          <el-col :span="8">
            <el-form-item label="主容量">
              <el-input v-model="dataForm.primaryCapacity"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="次容量">
              <el-input v-model="dataForm.secondaryCapacity"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8"></el-col>
        </el-row>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="searchHandle">查询</el-button>
          <el-button type="info" icon="el-icon-delete" @click="clearSearchForm">清空</el-button>
        </el-form-item>
      </el-form>
      <el-divider content-position="left">查询数据</el-divider>
      <div class="avue-crud__pagination" style="margin-bottom: 25px;">
        <el-button icon="el-icon-check" type="primary" @click="determineGoods" size="mini">选择并关闭</el-button>
        <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
          :page-sizes="[10, 20, 50, 100, 200]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next">
        </el-pagination>
      </div>

      <div v-if="tableShow" style="margin-bottom: ;">
        <div class="avue-crud">
          <el-table :data="dataList" height="calc(100vh - 215px)" ref="goodsTable" border v-loading="dataListLoading" @select-all="selectAll" @select="onTableSelect" @selection-change="handleSelectionChange">
            <el-table-column key="1" type="selection" width="45"></el-table-column>
            <el-table-column key="2" prop="code" label="商品代码"></el-table-column>
            <el-table-column key="3" prop="name" label="商品名称"></el-table-column>
            <el-table-column key="4" prop="spec" label="型号" width="100"></el-table-column>
            <el-table-column key="5" prop="unitType" label="单位" width="80">
              <template slot-scope="scope"> {{getNameByKey(unitTypeData,scope.row.unitType)}} </template>
            </el-table-column>

            <el-table-column key="6" prop="mirrorBall" label="老花镜度数" width="100" v-if="ctgId == 8"></el-table-column>
            <el-table-column key="7" prop="manufacturerColorNumber" label="厂家色号" width="90" v-if="[1,6,8].includes(ctgId)"></el-table-column>
            <el-table-column key="8" prop="frameMaterial" label="镜架材质" width="90" v-if="ctgId == 1">
              <template slot-scope="scope"> {{getNameByKey(frameMaterialData,scope.row.frameMaterial)}} </template>
            </el-table-column>
            <el-table-column key="9" prop="goodsSize" label="镜架尺寸" width="90" v-if="[1,6,8].includes(ctgId)"></el-table-column>

            <el-table-column key="10" prop="accessoriesType" label="配件型" width="80" v-if="ctgId == 2">
              <template slot-scope="scope"> {{getNameByKey(accessoryTypeData,scope.row.accessoriesType)}} </template>
            </el-table-column>

            <el-table-column key="11" prop="mirrorBall" label="球镜" width="80" v-if="[3,4].includes(ctgId) && customizeType == 0"></el-table-column>
            <el-table-column key="12" prop="columnMirror" label="柱镜" width="80" v-if="[3,4].includes(ctgId) && customizeType == 0"></el-table-column>

            <el-table-column key="13" label="球镜" width="120" v-if="[3,4].includes(ctgId) && customizeType == 1">
              <template slot-scope="scope">
                <span v-if="scope.row.customizedMirrorBallMin && scope.row.customizedMirrorBallMax">
                  {{scope.row.customizedMirrorBallMin}} / {{scope.row.customizedMirrorBallMax}}
                </span>
              </template>
            </el-table-column>
            <el-table-column key="14" label="柱镜" width="120" v-if="[3,4].includes(ctgId) && customizeType == 1">
              <template slot-scope="scope">
                <span v-if="scope.row.customizedColumnMirrorMin && scope.row.customizedColumnMirrorMax">
                  {{scope.row.customizedColumnMirrorMin}} / {{scope.row.customizedColumnMirrorMax}}
                </span>
              </template>
            </el-table-column>

            <el-table-column key="15" prop="toTheLight" label="下加光" width="80" v-if="ctgId == 3 && customizeType == 0"></el-table-column>
            <el-table-column key="16" label="下加光" width="80" v-if="ctgId == 3 && customizeType == 1">
              <template slot-scope="scope">
                <span v-if="scope.row.toTheLightMin && scope.row.toTheLightMax">
                  {{scope.row.toTheLightMin}} / {{scope.row.toTheLightMax}}
                </span>
              </template>
            </el-table-column>
            <el-table-column key="17" prop="refractiveIndex" label="折射率" width="80" v-if="ctgId == 3"></el-table-column>
            <el-table-column key="18" label="镜片分类" width="80" v-if="ctgId == 3">
              <template slot-scope="scope"> {{getNameByKey(bizData.photometricClassification,scope.row.photometricClassification)}} </template>
            </el-table-column>
            <el-table-column key="19" prop="lensMaterial" label="材料分类" width="80" v-if="ctgId == 3">
              <template slot-scope="scope"> {{getNameByKey(bizData.lensMaterial,scope.row.lensMaterial)}} </template>
            </el-table-column>
            <el-table-column key="20" prop="progressiveSliceClassification" label="渐进片分类" width="100" v-if="ctgId == 3">
              <template slot-scope="scope"> {{getNameByKey(bizData.progressiveSliceClassification,scope.row.progressiveSliceClassification)}} </template>
            </el-table-column>
            <el-table-column key="21" prop="lensFunction" label="镜片功能" width="80" v-if="ctgId == 3">
              <template slot-scope="scope"> {{getNameByKey(lensFunction,scope.row.lensFunction)}} </template>
            </el-table-column>
            <el-table-column key="22" prop="curvature" label="曲率" width="80" v-if="ctgId == 4 && customizeType == 0"></el-table-column>
            <el-table-column key="23" prop="diameter" label="直径" width="80" v-if="ctgId == 4 && customizeType == 0"></el-table-column>
            <el-table-column key="24" label="曲率" width="120" v-if="ctgId == 4 && customizeType == 1">
              <template slot-scope="scope">
                <span v-if="scope.row.curvatureMin && scope.row.curvatureMax">
                  {{scope.row.curvatureMin}} / {{scope.row.curvatureMax}}
                </span>
              </template>
            </el-table-column>
            <el-table-column key="25" prop="spec" label="直径" width="120" v-if="ctgId == 4 && customizeType == 1">
              <template slot-scope="scope">
                <span v-if="scope.row.diameterMin && scope.row.diameterMax">
                  {{scope.row.diameterMin}} / {{scope.row.diameterMax}}
                </span>
              </template>
            </el-table-column>
            <el-table-column key="26" prop="useType" label="使用类型" width="80" v-if="ctgId == 4">
              <template slot-scope="scope"> {{getNameByKey(bizData.useType,scope.row.useType)}} </template>
            </el-table-column>
            <el-table-column key="27" prop="disusedClassification" label="抛弃类型" width="80" v-if="ctgId == 4">
              <template slot-scope="scope"> {{getNameByKey(bizData.disusedClassification,scope.row.disusedClassification)}} </template>
            </el-table-column>
            <el-table-column key="28" prop="primaryCapacity" label="主容量" width="80" v-if="ctgId == 5"></el-table-column>
            <el-table-column key="29" prop="secondaryCapacity" label="次容量" width="80" v-if="ctgId == 5"></el-table-column>
            <el-table-column key="30" prop="batch" label="批次" width="100" v-if="[4,5].includes(ctgId)"></el-table-column>
            <el-table-column key="31" prop="invalidStr" label="效期" width="120" v-if="[4,5].includes(ctgId)">
              <template slot-scope="scope">
                {{changeTimeType(scope.row.invalidStr)}}
              </template>
            </el-table-column>
            <el-table-column key="32" prop="goodsPrice" label="销售价格" width="80"></el-table-column>
            <el-table-column key="33" prop="stockName" label="仓位" width="120"></el-table-column>
            <el-table-column key="34" prop="storageQuantity" label="数量" width="60"></el-table-column>
          </el-table>
          <!-- <div class="avue-crud__pagination" style="margin-bottom: 25px;">
            <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
              :page-sizes="[10, 20, 50, 100, 200]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next">
            </el-pagination>
          </div> -->
        </div>
      </div>
      <search-supply v-if="supplyVisible" ref="supplyDialog" @refreshData="getSupplyData"></search-supply>
      <search-brand v-if="brandVisible" ref="brandDialog" @refreshData="getBrandData"></search-brand>
  </el-dialog>
</template>

<script>
  import {filterParams,deduplication, deduplicationBykey} from '@/util/tools'
  import { remote } from '@/api/admin/dict'
  import {getGoodsStorage} from '@/api/eims/storage'
  import { getCtgList } from '@/api/eims/ctg'

  import SearchSupply from '@/components/business/SearchSupply'
  import SearchBrand from '@/components/business/SearchBrand'

  import {mapGetters} from 'vuex'
  export default {
    data () {
      return {
        visible: false,
        unitTypeData: [],
        frameMaterialData: [],
        craftTypeData: [],
        lensFunction: [],
        accessoryTypeData: [],
        ctgId: '',
        customizeType: '',
        tableShow: false,
        paramsData: {},
        dataForm: {
          customizeType: '0',
          storageType: '1'
        },
        selected: true,
        rowItem: {},
        dataList: [],
        pageIndex: 1,
        pageSize: 200,
        totalPage: 0,
        selectList: [],
        dataListLoading: false,
        goodsCtgOptions: [],
        supplyVisible: false,
        brandVisible: false
      }
    },
    components: {
      SearchSupply,
      SearchBrand
    },
    computed: {
      ...mapGetters(['permissions','bizData'])
    },
    methods: {
      init(data) {
        this.visible = true
        this.selected = true
        remote('unit_type').then(result => {
          this.unitTypeData = result.data.data
        })
        remote('frame_material').then(result => {
          this.frameMaterialData = result.data.data
        })
        remote('craft_type').then(result => {
          this.craftTypeData = result.data.data
        })
        remote('lens_function').then(result => {
          this.lensFunction = result.data.data
        })
        remote('accessory_type').then(result => {
          this.accessoryTypeData = result.data.data
        })
        this.paramsData = data.paramsData
        this.tableData = data.tableData
        this.selectList = data.tableData
        for(let key in this.dataForm){
          this.dataForm[key] = ''
        }
        this.dataForm.stockName = this.paramsData.stockName
        this.getGoodsCtgList()
        this.dataList = []
      },
      //  清空搜索表单
      clearSearchForm() {
        for(let key in this.dataForm){
          if(key != 'stockName'){
            this.dataForm[key] = ''
          }
        }
      },
      //  商品类别改变
      ctgChangeHandle(val) {
        for(let key in this.dataForm){
          if(key != 'storageType' && key != 'ctgId' && key != 'stockName') {
            this.dataForm[key] = ''
          }
        }
        if([3,4].includes(val)){
          this.dataForm.customizeType = '0'
        }
      },
      searchHandle(){
        this.pageIndex = 1
        this.getDataList()
      },
      // 获取数据列表
      getDataList () {
        if(!this.dataForm.ctgId) {
          this.$message.warning('商品类别不能为空')
          return false
        }
        this.tableShow = true
        this.dataListLoading = true
        this.dataForm.stockId = this.paramsData.stockId
        let params1 = { current: this.pageIndex, size: this.pageSize }
        let params2 = filterParams(this.dataForm)
        this.ctgId = this.dataForm.ctgId
        this.customizeType = this.dataForm.customizeType

        getGoodsStorage(Object.assign(params1,params2)).then(result => {
          this.dataList = result.data.data.records
          this.dataList.forEach(item => {
            item.goodsId = item.id
          })
          this.totalPage = result.data.data.total
          this.$nextTick(() => {
            this.selectList.forEach(item => {
              for(let i = 0; i < this.dataList.length; i++){
                if(this.dataForm.ctgId == '4' || this.dataForm.ctgId == '5'){
                  if(this.dataList[i].goodsId == item.goodsId && this.dataList[i].batch == item.batch && this.dataList[i].invalidTime == item.invalidTime){
                    this.$refs.goodsTable.toggleRowSelection(this.dataList[i],true)
                  }
                }else{
                  if(this.dataList[i].goodsId == item.goodsId){
                    this.$refs.goodsTable.toggleRowSelection(this.dataList[i],true)
                  }
                }
              }
            })
          })
        })
        this.dataListLoading = false
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      //  判断当前操作的属性是勾选还是取消勾选
      onTableSelect(rows,row) {
        this.selected = rows.length && rows.indexOf(row) !== -1
        this.rowItem = row
      },
      //  全选改变事件
      selectAll(val) {
        if(!val.length) this.selectList = this.tableData
      },
      //  表格改变事件
      handleSelectionChange(val) {
        val.forEach(item => {
          if(item.id){
            item.goodsId = item.id
          }
        })
        if(this.selected) {
          this.selectList = deduplicationBykey(this.selectList.concat(val),'goodsId','batch','invalidTime')
        }else{
          this.selectList.forEach((item,index) => {
            if(item.goodsId == this.rowItem.goodsId){
              this.selectList.splice(index,1)
            }
          })
        }
      },
      //  确认选择商品
      determineGoods() {
        let list = JSON.parse(JSON.stringify(this.selectList))
        list.forEach((item, index) => {
          item.allocationQuantity = 1
          if (this.tableData.length) {
            for (let i = 0; i < this.tableData.length; i++) {
              let idVal = this.tableData[i].goodsId
              if (item.goodsId == idVal && item.batch == this.tableData[i].batch && item.invalidTime == this.tableData[i].invalidTime) {
                item.allocationQuantity = this.tableData[i].allocationQuantity
                if (item.ctgId == '4' || item.ctgId == '5') {
                  item.invalidTime = this.tableData[i].invalidTime
                  item.batch = this.tableData[i].batch
                }
              }
            }
          }
        })
        this.visible = false
        this.$emit('showBrandList',list)
      },
      //  查询商品类别列表
      getGoodsCtgList() {
        getCtgList().then(result => {
          this.goodsCtgOptions = result.data.data
        })
      },
      //  打开弹窗
      openDialog(name) {
        if(!this.dataForm.ctgId) {
          this.$message.warning('请选择商品类别')
          return false
        }
        switch (name) {
          case 'supply':
            this.supplyVisible = true
            this.$nextTick(() => {
              this.$refs.supplyDialog.init({ctgId: this.dataForm.ctgId})
            })
            break
          case 'brand':
            if(!this.dataForm.supplyId){
              this.$message.warning('请选择制造商')
              return false
            }
            this.brandVisible = true
            this.$nextTick(() => {
              let data = {
                ctgId: this.dataForm.ctgId,
                supplyId: this.dataForm.supplyId
              }
              this.$refs.brandDialog.init(data)
            })
            break
        }
      },
      getSupplyData(data) {
        this.$set(this.dataForm,'supplyId',data.id)
        this.$set(this.dataForm,'supplyName',data.name)
      },
      getBrandData(data) {
        this.$set(this.dataForm,'brandId',data.id)
        this.$set(this.dataForm,'brandName',data.name)
      },
      //  根据key值获取名称
      getNameByKey(data,key) {
        let obj = {}
        obj = data.find(item => {
          return item.value == key
        })
        if(obj && obj.label){
          return obj.label
        }
      },
      //  截取日期字符串
      changeTimeType(value) {
        let valStr = (value) ? value.slice(0,10) : ''
        return valStr
      }
    }
  }
</script>
